home *** CD-ROM | disk | FTP | other *** search
/ Chip 2003 October / Chip Ekim 2003.iso / prog / code / contr / setup.exe / Disk1 / data1.cab / Paypal_En / Configuration / Commands / Insert PayPal Buy Now.js < prev    next >
Encoding:
JavaScript  |  2003-07-18  |  12.7 KB  |  441 lines

  1. /*-----------------------------------------------------------------------------
  2. -    File Name:
  3. -        Insert PayPal Single Item.js
  4. -
  5. -    Description:
  6. -        Functions for Single Item Purchase wizard.
  7. -
  8. -    This file contains proprietary and confidential information from WebAssist.com
  9. -    corporation.  Any unauthorized reuse, reproduction, or modification without
  10. -    the prior written consent of WebAssist.com is strictly prohibited.
  11. -
  12. -    Copyright 2001 WebAssist.com Corporation.  All rights reserved.
  13. ------------------------------------------------------------------------------*/
  14. var CURRENTPAGE=0;
  15.  
  16. function commandButtons()     {
  17.   return new Array();
  18. }
  19.  
  20. /* Initialize the UI.  First thing that's called on the body load event. */
  21. function initializeUI()     {
  22.   if (navigator.platform.toLowerCase().indexOf("mac") >= 0)     {
  23.     document.cancel.style = "position:absolute; width:70px; height:20px; z-index:90; left: 245px; top: 397px; visibility: visible";
  24.     document.cancel.document.btnCancel.style = "width:63; height:20; font-family:'Lucidia Grande'; font-size: 13px";
  25.         
  26.     document.help.style = "position:absolute; width:70px; height:20px; z-index:90; left: 175px; top: 397px; visibility: visible";
  27.     document.help.document.btnHelp.style = "width:63; height:20; font-family:'Lucidia Grande'; font-size: 13px";
  28.         
  29.     document.next.style = "position:absolute; width:70px; height:20px; z-index:90; left: 385px; top: 397px; visibility: visible";
  30.     document.next.document.btnNext.style = "width:63; height:20; font-family:'Lucidia Grande'; font-size: 13px";
  31.         
  32.     document.back.style = "position:absolute; width:70px; height:20px; z-index:90; left: 315px; top: 397px; visibility: visible";
  33.     document.back.document.btnBack.style = "width:63; height:20; font-family:'Lucidia Grande'; font-size: 13px";
  34.         
  35.     document.finish.style = "position:absolute; width:70px; height:20px; z-index:90; left: 385px; top: 397px; visibility: visible";
  36.     document.finish.document.btnFinish.style = "width:63; height:20; font-family:'Lucidia Grande'; font-size: 13px";
  37.   
  38.     document.walogo.top = 402;
  39.     document.pplogo.top = 403;
  40.   
  41.   }
  42.   document.back.visibility = "visible";
  43.   document.next.visibility = "visible";
  44.   document.help.visibility = "visible";
  45.   document.cancel.visibility = "visible";
  46.   var theDOM = dreamweaver.getDocumentDOM();
  47.   var theParent = theDOM.getSelectedNode();
  48.   var inForm = false;
  49.   while (theParent.parentNode)  {
  50.     theParent = theParent.parentNode;
  51.     if (theParent.tagName=="FORM")  {
  52.         inForm = theParent;
  53.         break;
  54.     }
  55.     }
  56.   if (inForm)  {
  57.     if (inForm.innerHTML.search(/<input type="[^"]*"[^>]*\sname="cmd"[^>]*>/i)>=0)  
  58.     {
  59.         alert(MSG_AlreadyPayPalInForm);
  60.         window.close();
  61.     }
  62.   }
  63.   MM.setBusyCursor();
  64.   showPageNum(0);
  65.   getLastUID();  
  66.   enableDisableOtherImage();
  67.   MM.clearBusyCursor();
  68. }
  69.  
  70. /******************************** support functions ******************/
  71. function buildSummaryText()     {
  72.   var retVal = "";
  73.   var myID       = findObject("ppUID").value;
  74.   var myImage    = findObject("sipimage");
  75.   var myImageURL = "";
  76.   var myItemName = findObject("itemName").value;
  77.   var myItemID = findObject("itemID").value;
  78.   var myAmount = findObject("itemPrice").value;
  79.   var myCurrency = findObject("itemCurrency").options[findObject("itemCurrency").selectedIndex].value;    
  80.   var myQuantityYes = findObject("quantityYes").checked;
  81.   var myShipping = findObject("itemShipping").value;
  82.   var myShipping2 = findObject("itemShipping2").value;
  83.   var myHandling = findObject("itemHandling").value;  
  84.   var myShippingYes = true;
  85.   if (findObject("shippingNo")[1].checked)
  86.   {
  87.     myShippingYes = false;
  88.   }
  89.   var myIncludeNote = true;
  90.   if (findObject("includeNote")[1].checked)
  91.   {
  92.     myIncludeNote = false;
  93.   }
  94.   var myLogoURL = findObject("ppLogo").value;
  95.   var mySuccessURL = findObject("successURL").value;
  96.   var myCancelURL = findObject("cancelURL").value;
  97.     
  98.   retVal += "PayPal Account: " + myID;
  99.   retVal += "\n";
  100.   retVal += "Button Image URL: ";
  101.   for (var n=0; n<myImage.length; n++)
  102.   {
  103.     if (myImage[n].checked)
  104.     {
  105.       if (myImage[n].value == "other")
  106.       {
  107.         retVal += findObject("othersipimage").value;      
  108.       }
  109.       else
  110.       {
  111.         retVal += "http://images.paypal.com/images/" + myImage[n].value;      
  112.       }
  113.     }
  114.   }
  115.   retVal += "\n";
  116.   
  117.   if (myItemName != "")
  118.   {
  119.     retVal += "Item Name: " + myItemName + "\n";
  120.   }
  121.   
  122.   if (myItemID != "")
  123.   {
  124.     retVal += "Item Number: " + myItemID + "\n";  
  125.   }
  126.   
  127.   if (myAmount != "")
  128.   {
  129.     retVal += "Item Amount: " + myAmount + "\n";    
  130.   }
  131.   
  132.   retVal += "Currency: " + getCurrencyType(myCurrency) + "\n";    
  133.   
  134.   retVal += "Allow Customer to Edit Quantity: ";    
  135.   if (myQuantityYes)
  136.     retVal += "Yes";
  137.   else
  138.     retVal += "No";  
  139.   retVal +="\n";      
  140.  
  141.   if (myShipping != "")
  142.   {
  143.     retVal += "Base Shipping: $" + myShipping + "\n";    
  144.   }
  145.       
  146.   if (myShipping2 != "")
  147.   {
  148.     retVal += "Extra Shipping: $" + myShipping2 + "\n";    
  149.   }
  150.   
  151.   if (myHandling != "")
  152.   {
  153.     retVal += "Handling: $" + myHandling + "\n";    
  154.   }
  155.     
  156.   retVal += "Require Shipping Information: ";    
  157.   if (!myShippingYes)
  158.     retVal += "No";
  159.   else
  160.     retVal += "Yes";
  161.   retVal +="\n";
  162.          
  163.   retVal += "Allow Customer Note: ";    
  164.   if (!myIncludeNote)
  165.     retVal += "No";
  166.   else
  167.     retVal += "Yes";  
  168.   retVal +="\n";
  169.   
  170.   if (isValidURL(myLogoURL))
  171.   {
  172.     retVal += "Custom Logo URL: " + myLogoURL + "\n";
  173.   }
  174.   
  175.   if (isValidURL(mySuccessURL))
  176.   {
  177.     retVal += "Successful Payment URL: " + mySuccessURL + "\n";
  178.   }
  179.   
  180.   if (isValidURL(myCancelURL))
  181.   {
  182.     retVal += "Cancelled Payment URL: " + myCancelURL + "\n";
  183.   }
  184.         
  185.   return retVal;
  186. }
  187.  
  188. function enableDisableOtherImage()     {
  189.   var myImage = findObject("sipimage");
  190.   for (var n=0; n<myImage.length; n++)
  191.   {
  192.     if (myImage[n].checked)
  193.     {
  194.       if (myImage[n].value == "other")
  195.       {
  196.         findObject("othersipimage").disabled = "enabled";
  197.         findObject("ImageBrowse").disabled = "enabled";
  198.       }
  199.       else
  200.       {
  201.         findObject("othersipimage").disabled = "disabled";
  202.         findObject("ImageBrowse").disabled = "disabled";
  203.       }
  204.     }
  205.   }
  206. }
  207.  
  208. function openBrowseImageWindow()      {
  209.   var browseURL = "";
  210.   var LABEL_Select = "Select Single Item Purchase Image...";  // label for file window
  211.   browseURL = dreamweaver.browseForFileURL("select",LABEL_Select, false, true); // opens file window and returns file string as URL
  212.   if (browseURL)
  213.   {
  214.     //browseURL = WA_absoluteToRelativeURL(browseURL, docpath, false);          
  215.     findObject("othersipimage").value = browseURL;  //set the DataSource    
  216.   }
  217.   findObject("othersipimage").focus();
  218. }
  219.  
  220. /****************************** page functions ****************************/
  221. function Pg0_load()
  222. {
  223.   document.UserIDWP.visibility = "visible";
  224.   findObject("btnBack").setAttribute("disabled", "disabled"); // disable the back button
  225.   findObject("next").visibility = "visible";                  // enable next button
  226.   findObject("finish").visibility = "hidden";                 // hide finish button
  227.  
  228.   // Set focus but this only seems to work if you delay the page loading by some amount of time (in msec)
  229.   setTimeout('findObject("ppUID").focus()',500);
  230.   return true;
  231. }
  232.  
  233. function Pg0_unLoad()
  234. {
  235.   document.UserIDWP.visibility = "hidden";
  236.   return true;
  237. }
  238.  
  239. function Pg1_canLoad()      {
  240.   var ppError = validatePPUID();
  241.   if (ppError != "")
  242.   {
  243.     alert ("Account " + ppError);
  244.     return false;
  245.   }
  246.   return true;
  247. }
  248.  
  249. function Pg1_load()
  250. {
  251.   document.ButtonImageWP.visibility = "visible";
  252.   findObject("btnBack").setAttribute("disabled", "enabled"); // disable the back button
  253.   findObject("next").visibility = "visible";                  // enable next button
  254.   findObject("finish").visibility = "hidden";                 // hide finish button
  255.     
  256. // Set focus but this only seems to work if you delay the page loading by some amount of time (in msec)
  257.   setTimeout('findObject("sipimage")[0].focus()',500);
  258.   return true;
  259. }
  260.  
  261. function Pg1_unLoad()
  262. {
  263.   document.ButtonImageWP.visibility = "hidden";
  264.   return true;
  265. }
  266.  
  267. function Pg2_canLoad() 
  268. {
  269.   return true;
  270. }
  271.  
  272. function Pg2_load()
  273. {
  274.   document.itemWP.visibility = "visible";
  275.   findObject("btnBack").setAttribute("disabled", "enabled"); // disable the back button
  276.   findObject("next").visibility = "visible";                  // enable next button
  277.   findObject("finish").visibility = "hidden";                 // hide finish button
  278.  
  279.   // Set focus but this only seems to work if you delay the page loading by some amount of time (in msec)
  280.   setTimeout('findObject("itemName").focus()',500);
  281.   return true;
  282. }
  283.  
  284. function Pg2_unLoad()
  285. {
  286.   document.itemWP.visibility = "hidden";
  287.   return true;
  288. }
  289.  
  290. function Pg3_canLoad() 
  291. {
  292.   var myAmount = findObject("itemPrice").value;
  293.   
  294.   if (myAmount != "")
  295.   {
  296.     var amountErrMsg = validateItemPrice(myAmount);
  297.     if (amountErrMsg != "")
  298.     {
  299.       alert ("Item Price " + amountErrMsg);
  300.       return false;
  301.     }
  302.   }
  303.   return true;
  304. }
  305.  
  306. function Pg3_load()
  307. {
  308.   document.shippingWP.visibility = "visible";
  309.   findObject("btnBack").setAttribute("disabled", "enabled"); // disable the back button
  310.   findObject("next").visibility = "visible";                  // enable next button
  311.   findObject("finish").visibility = "hidden";                 // hide finish button
  312.  
  313.   // Set focus but this only seems to work if you delay the page loading by some amount of time (in msec)
  314.   setTimeout('findObject("itemShipping").focus()',500);
  315.   return true;
  316. }
  317.  
  318. function Pg3_unLoad()
  319. {
  320.   document.shippingWP.visibility = "hidden";
  321.   return true;
  322. }
  323.  
  324. function Pg4_canLoad() 
  325. {
  326.   var errMsg = "";
  327.   var myShipping = findObject("itemShipping").value;
  328.   var myShipping2 = findObject("itemShipping2").value;
  329.   var myHandling = findObject("itemHandling").value;
  330.   var shippingErrMsg = validateAmount(myShipping);
  331.   var shipping2ErrMsg = validateAmount(myShipping2);     
  332.   var handlingErrMsg = validateAmount(myHandling);
  333.  
  334.   if ( (myShipping != "") && (shippingErrMsg != "") )
  335.   {
  336.     errMsg += "Base Shipping " + shippingErrMsg;
  337.   }
  338.   
  339.   if ( (myShipping2 != "") && (shipping2ErrMsg != "") )
  340.   {
  341.     errMsg += "Extra Shipping " + shipping2ErrMsg;
  342.   }
  343.   
  344.   if ( (myHandling != "") && (handlingErrMsg != "") )
  345.   {
  346.     errMsg += "Handling " + handlingErrMsg;
  347.   }
  348.       
  349.   if (errMsg != "")
  350.   {
  351.     alert (errMsg);
  352.     return false;
  353.   }
  354.   
  355.   return true;
  356. }
  357.  
  358. function Pg4_load()
  359. {
  360.   document.logoWP.visibility = "visible";
  361.   findObject("btnBack").setAttribute("disabled", "enabled"); // disable the back button
  362.   findObject("next").visibility = "visible";                  // enable next button
  363.   findObject("finish").visibility = "hidden";                 // hide finish button
  364.  
  365.   // Set focus but this only seems to work if you delay the page loading by some amount of time (in msec)
  366.   setTimeout('findObject("ppLogo").focus()',500);
  367.   return true;
  368. }
  369.  
  370. function Pg4_unLoad()
  371. {
  372.   document.logoWP.visibility = "hidden";
  373.   return true;
  374. }
  375.  
  376. function Pg5_canLoad() 
  377. {
  378.   return true;
  379. }
  380.  
  381. function Pg5_load()
  382. {
  383.   document.customWP.visibility = "visible";
  384.   findObject("btnBack").setAttribute("disabled", "enabled"); // disable the back button
  385.   findObject("next").visibility = "visible";                  // enable next button
  386.   findObject("finish").visibility = "hidden";                 // hide finish button
  387.  
  388.   // Set focus but this only seems to work if you delay the page loading by some amount of time (in msec)
  389.   setTimeout('findObject("successURL").focus()',500);
  390.   return true;
  391. }
  392.  
  393. function Pg5_unLoad()
  394. {
  395.   document.customWP.visibility = "hidden";
  396.   return true;
  397. }
  398.  
  399. function Pg6_canLoad() 
  400. {
  401.   return true;
  402. }
  403.  
  404. function Pg6_load()
  405. {
  406.   document.SummaryWP.visibility = "visible";
  407.   findObject("btnBack").setAttribute("disabled", "enabled"); // disable the back button
  408.   findObject("next").visibility = "hidden";                  // enable next button
  409.   findObject("finish").visibility = "visible";                 // hide finish button
  410.  
  411.   findObject("summaryText").value = buildSummaryText();
  412.   return true;
  413. }
  414.  
  415. function Pg6_unLoad()
  416. {
  417.   document.SummaryWP.visibility = "hidden";
  418.   return true;
  419. }
  420.  
  421. function showNextPage()   {
  422.   var nextPage = CURRENTPAGE + 1;
  423.   if (eval("Pg"+nextPage+"_canLoad()"))
  424.   {
  425.     eval("Pg"+CURRENTPAGE+"_unLoad()");
  426.     CURRENTPAGE++;
  427.     eval("Pg"+CURRENTPAGE+"_load()");  
  428.   }
  429. }
  430.  
  431. function showPreviousPage()   {
  432.   eval("Pg"+CURRENTPAGE+"_unLoad()");
  433.   CURRENTPAGE--;
  434.   eval("Pg"+CURRENTPAGE+"_load()");
  435. }
  436.  
  437. function showPageNum(pageNum)  {
  438.   eval("Pg"+CURRENTPAGE+"_unLoad()");
  439.   CURRENTPAGE = pageNum;
  440.   eval("Pg"+CURRENTPAGE+"_load()");
  441. }